package net.soevar.database.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

@Entity
@Table(schema = "public", name = "ath_log_login")
public class AthLogLogin implements Serializable {
	private static final long serialVersionUID = 2941156384313930467L;
	private Long id;
	private String nama;
	private String ip;
	private String keterangan;
	private Date login = new Date();
	private Date logout;
	private AthUser athuser;
	private String hostname;
	private Boolean success_status;
	private String description;
	private String dirubahOleh;
	private Date dirubahTanggal = new Date();

	public AthLogLogin() {
	}

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "id", insertable = false, unique = true, nullable = false)
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@Column(name = "nama", nullable = false, length = 255)
	public String getNama() {
		return nama;
	}

	public void setNama(String nama) {
		this.nama = nama;
	}

	@Column(name = "ip", length = 64)
	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}

	@Column(name = "keterangan", nullable = true)
	public String getKeterangan() {
		return keterangan;
	}

	public void setKeterangan(String keterangan) {
		this.keterangan = keterangan;
	}

	@Column(name = "login")
	@Temporal(TemporalType.TIMESTAMP)
	public Date getLogin() {
		return login;
	}

	public void setLogin(Date login) {
		this.login = login;
	}

	@Column(name = "logout")
	@Temporal(TemporalType.TIMESTAMP)
	public Date getLogout() {
		return logout;
	}

	public void setLogout(Date logout) {
		this.logout = logout;
	}

	@ManyToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE })
	@Fetch(FetchMode.SELECT)
	@JoinColumn(name = "athuser", nullable = true)
	public AthUser getAthuser() {
		return athuser;
	}

	public void setAthuser(AthUser athuser) {
		this.athuser = athuser;
	}

	@Column(name = "hostname", length = 255)
	public String getHostname() {
		return hostname;
	}

	public void setHostname(String hostname) {
		this.hostname = hostname;
	}

	@Column(name = "status")
	public Boolean getSuccess_status() {
		return success_status;
	}

	public void setSuccess_status(Boolean success_status) {
		this.success_status = success_status;
	}

	@Column(name = "description", length = 255)
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Column(name = "dirubah_oleh", length = 100)
	public String getDirubahOleh() {
		return dirubahOleh;
	}

	public void setDirubahOleh(String dirubahOleh) {
		this.dirubahOleh = dirubahOleh;
	}

	@Column(name = "dirubah_tanggal")
	@Temporal(TemporalType.TIMESTAMP)
	public Date getDirubahTanggal() {
		return dirubahTanggal;
	}

	public void setDirubahTanggal(Date dirubahTanggal) {
		this.dirubahTanggal = dirubahTanggal;
	}

}
